#include<cstdio>
#include<cstring>
#include<queue>

#define CC(A,x) memset(A,x,sizeof(A))
using namespace std;

const int KIND=26;
const int maxn=1005;
const int maxm=2000005;
const int maxnode=KIND*maxn;

int chd[maxnode][KIND],fail[maxnode],id[maxnode];
int C;

char ch[maxm],key[maxn][55];
int cnt[maxn];

void init()
{
	CC(chd,0);
	CC(fail,0);
	C=1;
}

void insert(char *ch,int num)
{
    int p=0;
    int i=0,t;
    while(ch[i])
    {
        t=ch[i]-'A';
        if(!chd[p][t])chd[p][t]=C++;
        p=chd[p][t];
        i++;
    }
	id[p]=num;	
}

void AC()
{
    queue<int>q;
	int root=0;
    q.push(root);
    while(!q.empty())
    {
        int t=q.front();
        int p=0;
        q.pop();
        for(int i=0;i<KIND;i++)
        {
            if(chd[t][i])
            {
                p=fail[t];
                while(p)
                {
                    if(chd[p][i])
                    {
                        fail[chd[t][i]]=chd[p][i];
                        break;
                    }
                    p=fail[p];
                }
				if(!p)
				{
					if(t!=0&&chd[p][i])fail[chd[t][i]]=chd[p][i];
					else fail[chd[t][i]]=root;
				}
                q.push(chd[t][i]);
            }
        }
    }
}

void match(char *ch)
{
    int i=0,t,root=0;
    int p=root,temp;
    while(ch[i])
    {
        if(ch[i]>'Z'||ch[i]<'A')
        {
            p=root;
            i++;
            continue;
        }
        t=ch[i]-'A';
        while(!chd[p][t] &&p !=root) p=fail[p];
        p =chd[p][t];
        if(!p)p=root;
        temp=p;
        while(temp!=root)
        {
            cnt[id[temp]]++;
            temp = fail[temp];
        }
        i++;
    }
}

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        CC(cnt,0);
		init();
        for(int i=1;i<=n;i++)
        {
            scanf("%s",key[i]);
            insert(key[i],i);
        }
        AC();
        scanf("%s",ch);
        match(ch);
        for(int i=1;i<=n; i++)
        {
            if(cnt[i])
            {
                printf("%s: %d\n",key[i],cnt[i]);
            }
        }
    }
    return 0;
}
            
